package pl.word.app.security;

import org.jboss.seam.security.Identity;
import org.jboss.seam.security.annotations.Secures;

import pl.word.app.security.annotation.Admin;
import pl.word.app.security.annotation.User;
import pl.word.domain.model.RoleName;

/**
 * Klasa nakdajaca restrzkcje na kayda role.
 * 
 * @author and.lachowski
 * 
 */
public class Restrictions {

	public final static String SECURITY_GROUP = "WORD";

	public final static String SECURITY_GROUP_TYPE = "GROUP";

	@Secures
	@Admin
	public boolean isAdmin(Identity identity) {

		return identity.hasRole(RoleName.ADMIN.name(), SECURITY_GROUP,
				SECURITY_GROUP_TYPE);
	}

	@Secures
	@User
	public boolean isUser(Identity identity) {

		return identity.hasRole(RoleName.USER.name(), SECURITY_GROUP,
				SECURITY_GROUP_TYPE);
	}

}
